package com.situ.day2;

import java.util.Scanner;

import org.junit.Test;

public class lianxi {
	@Test
	public void test(Object newParam){
		int[] scre={0,0,1,2,3,5,4,5,2,8,7,6,9,5,4,8,3,1,0,2,4,8,7,9,5,2,1,2,3,9};
		int[] ch = new int[10];
		for (int i = 0; i < scre.length; i++) {
			switch (scre[i]) {
				case 0:
					ch[0]++;
					break;
				case 1:
					ch[1]++;
					break;
				case 2:
					ch[2]++;
					break;
				case 3:
					ch[3]++;
					break;
				case 4:
					ch[4]++;
					break;
				case 5:
					ch[5]++;
					break;
				case 6:
					ch[6]++;
					break;
				case 7:
					ch[7]++;
					break;
				case 8:
					ch[8]++;
					break;
				case 9:
					ch[9]++;
					break;
				default:
					System.out.println("错误");
					break;
			}
		}
		System.out.println("0的个数为：" + ch[0]);
		System.out.println("1的个数为：" + ch[1]);
		System.out.println("2的个数为：" + ch[2]);
		System.out.println("3的个数为：" + ch[3]);
		System.out.println("4的个数为：" + ch[4]);
		System.out.println("5的个数为：" + ch[5]);
		System.out.println("6的个数为：" + ch[6]);
		System.out.println("7的个数为：" + ch[7]);
		System.out.println("8的个数为：" + ch[8]);
		System.out.println("9的个数为：" + ch[9]);
	}
	@Test
	public void test2(){
		int[] score={0,0,1,2,3,5,4,5,2,8,7,6,9,5,4,8,3,1,0,2,4,8,7,9,5,2,1,2,3,9};
		int ji = 0;
		int ou = 0;
		for (int i = 0; i < score.length; i++) {
			if (score[i] % 2 == 0) {
				ou++;
			}else{
				ji++;
			}
		}
		System.out.println("偶数的个数：" + ou);
		System.out.println("奇数的个数：" + ji);
		
	}
//	输入一组学生的成绩，使用数组，然后计算他们的平均值.
	@Test
	public void test3(){
		int sum = 0;
		System.out.println("请输入学生的个数：");
		Scanner scanner = new Scanner(System.in);
		int ren = scanner.nextInt();
		int[] ch = new int[ren];
		for (int i = 0; i < ch.length; i++) {
			System.out.println("请输入第" + (i + 1) + "个学生的成绩");
			ch[i] = scanner.nextInt();					
			sum = sum + ch[i];
		}
		int pingjun = sum / ch.length;
		System.out.println(pingjun);
	}
//	一个5位数，判断它是不是回文数。即12321是回文数，个位与万位相同，十位与千位相同。
	@Test
	public void test4(){
		String str = "12321";
		char[] ch = str.toCharArray();
		boolean huiwen = true;
		for (int i = 0; i < ch.length / 2; i++) {
			if (ch[i] != ch[ch.length - i - 1]) {//ch[i] = ch[ch.length-i-1];
				huiwen = false;
				break;
			}
		}
		if (huiwen) {
			System.out.println("回文");
		}else{
			System.out.println("不是回文");
			
		}
	}
	
//	输入一行字符，分别统计出其中英文字母、空格、数字和其它字符的个数。
	@Test
	public void test6(){
		int zimu = 0;
		int kongge = 0;
		int shuzi = 0;
		int zi = 0;
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入一串字符");
		String chuan = scanner.nextLine();
		char[] ch = chuan.toCharArray();
		for (int i = 0; i < ch.length; i++) {
			if ((ch[i] >= 'a' && ch[i] <= 'z')|| (ch[i] >= 'A' && ch[i] <= 'Z')) {
				zimu = zimu +1;
			}
			else if (ch[i]  >= '0' && ch[i] <= '9') {
				shuzi = shuzi + 1;
			}
			else if (ch[i] == ' ') {
				kongge = kongge + 1;
			}else {
				zi = zi + 1;
			}
		}
		System.out.println("字母的个数为：" + zimu);
		System.out.println("数字的个数为：" + shuzi);
		System.out.println("空格的个数为：" + kongge);
		System.out.println("字符的个数为：" + zi);
	}
	//输入三个整数x,y,z，请把这三个数由小到大输出
	
	}

